package com.itheima.reggie.controller;

import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Setmeal;
import com.itheima.reggie.domain.SetmealDish;
import com.itheima.reggie.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SetmealController {

    @Autowired
    private SetmealService setmealService;

    // 套餐列表
    @GetMapping("/setmeal/list")
    public ResultInfo findList(Long categoryId, Integer status) { // 1.接收参数
        // 2.调用service查询
        List<Setmeal> setmealList = setmealService.findList(categoryId, status);
        // 3.返回结果
        return ResultInfo.success(setmealList);
    }

    //查看套餐中的菜品
    @GetMapping("/setmeal/dish/{id}")
    public ResultInfo findDishById(@PathVariable("id") Long id){
        //调用service
        List<SetmealDish> setmealDishList= setmealService.findDishById(id);
        //返回结果
        return ResultInfo.success(setmealDishList);
    }
}
